/*
 * @FileDescription:
 * @Author: dlh
 * @Date: 2021-11-22 16:45:24
 * @LastEditors: dlh
 * @LastEditTime: 2021-11-22 17:21:45
 */
export default {
    /**
     * 判断arr是否为数组
     * @param   {Array}     arr
     * @return  {Boolean}
     */
    isArray(arr) {
        return Object.prototype.toString.call(arr) === "[object Array]";
    },
    /**
     * 伪类数组鉴别以及转换
     * @param {Object} ar
     * @return {true/false}
     */
    ToIdentify(ar) {
        return ar.push || ar.pop || ar.map || ar.shift === undefined ? [...ar] : ar;
    },
    /**
     * 去除数组中假值元素，比如undefined,null,0,"",NaN都是假值
     * @param   {Array}    arr
     * @return  {Array}
     */
    compact(arr) {
        var index = -1,
            resIndex = -1,
            result = [],
            len = arr ? arr.length : 0;
        while (++index < len) {
            var value = arr[index];
            if (value) {
                result[++resIndex] = value;
            }
        }
        return result;
    },
};
